package com.aabbc.mongodb.repository;

import com.aabbc.mongodb.document.OrderDocument;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

/**
 * OrderRepository
 *
 * @author: <a href="mailto:chenfenghai@oristartech.com">chenfenghai</a>
 * @version: 1.0
 * @date: 2019-11-27 14:09
 */
public interface OrderRepository extends MongoRepository<OrderDocument, Long> {

    /**
     ** 分页查询满足条件： orderCode = orderCode and orderPrice >= orderPrice limit pageable
     */
    @Query(value = "{\"orderCode\":{\"$regex\":?0},\"orderPrice\":{\"$gte\":?1}}")
    Page<OrderDocument> findByCodeAndPrice(String orderCode, Double orderPrice, Pageable pageable);
}
